package com.nd.controller.admin;

import cn.hutool.core.lang.Dict;
import com.nd.pojo.bean.Jurisdiction;
import com.nd.pojo.bo.*;
import com.nd.pojo.vo.AdminAuthVO;
import com.nd.pojo.vo.AdministratorsOptionVO;
import com.nd.pojo.vo.ErrorAndErrno;
import com.nd.service.AdministratorsService;
import com.nd.service.JurisdictionService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: project2mall
 * @description: 管理员模块
 * @author: shit_code_builder
 * @create: 2021-06-04 20:07
 **/
@RestController
@RequestMapping("admin")
public class AdministratorsController {
    @Autowired
    JurisdictionService jurisdictionService;

    @Autowired
    AdministratorsService administratorsService;


    @GetMapping("/admin/list")
    ErrorAndErrno administratorsList(AdminAuthBO bo){

    ErrorAndErrno adminAuthVO = administratorsService.adminListSelect(bo);


        return adminAuthVO;
    }

   @GetMapping("/role/options")
   ErrorAndErrno selectAdministratorsAll(){

       ErrorAndErrno administratorsOptionVO = administratorsService.selectAdministratorsAll();


       return administratorsOptionVO;
   }

   @PostMapping("/admin/create")
    ErrorAndErrno createAdmin(@RequestBody AdminCreateBO bo) throws Exception {

       ErrorAndErrno errorAndErrno =  administratorsService.createAdmin(bo);


    return errorAndErrno;
   }

   @PostMapping("admin/update")
    ErrorAndErrno updateAdmin(@RequestBody AdminCreateBO bo){
       ErrorAndErrno errorAndErrno =  administratorsService.updateAdmin(bo);

       return errorAndErrno;
   }

   @PostMapping("/admin/delete")
   ErrorAndErrno deleteAdmin(@RequestBody AdminCreateBO bo){
       ErrorAndErrno errorAndErrno =  administratorsService.deleteAdmin(bo);
       return errorAndErrno;
   }

   @PostMapping("/in")//导入报表
    void inde(@RequestBody List<Player> playerList){

      jurisdictionService.addJurisdictionList(playerList);

   }

   @GetMapping("/role/list")
    ErrorAndErrno roleList(RoleBO bo ){
     ErrorAndErrno errorAndErrno=jurisdictionService.rolePremissionList(bo);

     return errorAndErrno;
   }

   @PostMapping("/role/update")
   ErrorAndErrno roleUpdate(@RequestBody RoleUpdateBO bo ) throws Exception {
       ErrorAndErrno errorAndErrno=jurisdictionService.roleUpdate(bo);

       return errorAndErrno;
   }

   @PostMapping("role/delete")
   ErrorAndErrno roleDelete(@RequestBody RoleUpdateBO bo ) throws Exception {
       ErrorAndErrno errorAndErrno=jurisdictionService.roleUpdate(bo);

       return errorAndErrno;
   }

   @PostMapping("/role/create")
   ErrorAndErrno roleAdd(@RequestBody RoleCreate bo ) throws Exception {
       ErrorAndErrno errorAndErrno=jurisdictionService.roleAdd(bo.getName(),bo.getDesc());

       return errorAndErrno;
   }
   @GetMapping("/role/permissions")
   ErrorAndErrno permissionsSelect(Integer roleId ) throws Exception {
       ErrorAndErrno errorAndErrno=jurisdictionService.selectRolePermission(roleId);

       return errorAndErrno;
   }

   @PostMapping("/role/permissions")
   ErrorAndErrno addPermissions(@RequestBody AddPerBO bo ) throws Exception {
       ErrorAndErrno errorAndErrno=jurisdictionService.addRolePermission(bo);

       return errorAndErrno;
   }


   @PostMapping("/profile/password")
   ErrorAndErrno changePassword(@RequestBody ChangePasswordBO bo ) throws Exception {
       ErrorAndErrno errorAndErrno=jurisdictionService.changePassword(bo);

       return errorAndErrno;
   }



}
